window.addEvent('domready', function() {
	//
    // Set up our dynamic navigation menu
    //
    
    var menus = $$(".navMenuBody");
    
    menus.each(function (m) {
        title = $(m.id + 'Div');
        
        //
        // Only create a nav menu if the element has a corresponding
        // title element
        //
        
        if(title)
        {
            title.myMenu = new Fx.Slide(m);
            title.myMenu.hide();
            
            title.addEvent('mouseenter', function(e) {
            	ev = new Event(e);
                
                this.myMenu.isClosing = false;
                this.myMenu.slideIn();
                
                ev.stop();
            });
            
            var closeMenus = function() {
            	$$('.navMenu').each(function (t) {
             		if(t.myMenu.isClosing)
                    	t.myMenu.slideOut();
                });   
            };
            
            title.addEvent('mouseleave', function(e) {
	            var ev = new Event(e);
                this.myMenu.isClosing = true;
            	closeMenus.delay(4000);
                ev.stop();
            });
        };
    });
});
